package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.User;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class UserDao {
	
	DBHelp<User> db = new DBHelp<User>();
	
	public User findUserByName(String name){
		String sql="select id,username,password from t_user where username=?";
		return db.executeQueryForObject(sql, new RowMapper<User>() {
			
			@Override
			public User mapRow(ResultSet rs) throws SQLException {
				User user=new User();
				user.setId(rs.getInt("id"));
				user.setUsername(rs.getString("username"));
				user.setPassword(rs.getString("password"));
				return user;
			}
		}, name);
	}
}
